package ln.gather.jsr.jcache.management;

import javax.cache.configuration.CompleteConfiguration;
import javax.cache.management.CacheMXBean;
import java.util.Objects;

/**
 *
 * @see CacheMXBean
 */
public class CacheMXBeanAdapter implements CacheMXBean {

    private final CompleteConfiguration<?, ?> configuration;

    public CacheMXBeanAdapter(CompleteConfiguration<?, ?> configuration) {
        Objects.requireNonNull(configuration);
        this.configuration = configuration;
    }


    /**
     * 是否 读穿透
     * @return
     */
    @Override
    public boolean isReadThrough() {
        return configuration.isReadThrough();
    }

    @Override
    public boolean isWriteThrough() {
        return configuration.isWriteThrough();
    }

    /**
     * 是否激活统计
     * @return
     */
    @Override
    public boolean isStatisticsEnabled() {
        return configuration.isStatisticsEnabled();
    }

    /**
     * 是否激活管理
     * @return
     */
    @Override
    public boolean isManagementEnabled() {
        return configuration.isManagementEnabled();
    }

    @Override
    public String getKeyType() {
        return configuration.getKeyType().getName();
    }

    @Override
    public String getValueType() {
        return configuration.getValueType().getName();
    }

    /**
     * 是否以值来进行传递<br/>
     * 有两种方式：值或者引用
     * @return
     */
    @Override
    public boolean isStoreByValue() {
        return configuration.isStoreByValue();
    }

}
